#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include <QMediaPlaylist>
#include "musiclist.h"

namespace Ui {
class CommonPage;
}

enum PageType
{
    LIKE_PAGE,   //喜欢
    LOCAL_PAGE,  //本地下载
    RECENT_PAGE  //最近播放
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

    void setCommonPageUI(const QString& title, const QString& imagePath);
    void upDateMusic(MusicList& musicList);

    void setPageType(PageType pageType);
    void addMusicToMusicPage(MusicList &musicList);
    void addMusicToPlaylist(MusicList& musicList, QMediaPlaylist* playlist);
    QString getMusicByIndex(int index);

    //设置封面图片
    void setMusicImage(QPixmap pixmap);

signals:
    void upDateLikeMusic(bool, const QString&);
    void playAllMusic(PageType);
    void playMusicByIndex(CommonPage*, int);

private:
    Ui::CommonPage *ui;

    PageType pageType;     //保存该页面的类别说明
    QVector<QString> musicListOfPage;   //保存 pageType 页面对应的歌曲Id
};

#endif // COMMONPAGE_H
